//
//  SettingHeaderCell.m
//  PhotographyStudi
//
//  Created by 叶一枫 on 2017/6/1.
//  Copyright © 2017年 叶一枫. All rights reserved.
//

#import "SettingHeaderCell.h"

@implementation SettingHeaderCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier UIType:(CELLENUM)UIType{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.UIType = UIType;
        [self initUI];
    }
    return self;
}

-(void)initUI{
    self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}


-(UIImageView *)headerAvatar{

    if (!_headerAvatar) {
        _headerAvatar = [[UIImageView alloc]initWithFrame:CGRectMake(15, 15, 50, 50)];
        _headerAvatar.contentMode = UIViewContentModeScaleAspectFill;
        _headerAvatar.layer.cornerRadius = 5;
        _headerAvatar.layer.borderWidth = 0.3;
        _headerAvatar.layer.borderColor = [UIColor darkTextColor].CGColor;
        _headerAvatar.layer.masksToBounds = YES;
        [self.contentView addSubview:_headerAvatar];
        _headerAvatar.userInteractionEnabled = YES;

        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageClick:)];
        tap.delegate = self;
        [_headerAvatar addGestureRecognizer:tap];
        
    }
    return _headerAvatar;
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
        return NO;
    }else {
        return YES;
    }
}

-(void)imageClick:(UITapGestureRecognizer*)tap{

    self.tapImage();
}


-(BaseLabel *)nickName{

    if (!_nickName) {
        _nickName = [[BaseLabel alloc]initWithFrame:CGRectMake(75, 20, VIEW_W - 110, 20)];
        [self.containView addSubview:_nickName];
    }
    return _nickName;
}

-(BaseLabel *)studiName{
    
    if (!_studiName) {
        _studiName = [[BaseLabel alloc]initWithFrame:CGRectMake(75, 40, VIEW_W - 110, 20)];
        _studiName.font = [UIFont systemFontOfSize:15];
        _studiName.textColor = [UIColor darkGrayColor];
        [self.containView addSubview:_studiName];
    }
    return _studiName;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
